package com.leiou.stu_login;

import com.leiou.utils.ConnectionDatabaseForSQLSeverUseJdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/*
 *蒋碧鹏
 *
 */
public class AdminloginDaoImpl implements AdminloginDao{
    Connection connection = null;
    PreparedStatement pstmt = null;
    ResultSet rset = null;

    public AdminloginDaoImpl() {connection  = ConnectionDatabaseForSQLSeverUseJdbc.getConnection();
    }

    //管理员登录
    @Override
    public boolean login(String account, String password) {

        try {
            pstmt=connection.prepareStatement("SELECT account FROM Admin WHERE account=? AND password=?");
            pstmt.setString(1, account);
            pstmt.setString(2, password);
            rset= pstmt.executeQuery();
            if(rset.next()){
                return true;
            }
        } catch (Exception e){
            e.printStackTrace();
        }

        return false;
    }
}
